Consider Result<T, Uninhabited> and ControlFlow<Uninhabited, T> to be equivalent to T for must use lint#148214
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
|
So, the lang team discussed this in the triage meeting today. Overall sentiment was positive that this is probably something we want to do at some point, but there was one concern: people may rely on this today to ensure that people "observe" the state of the fn foo<E>() -> Result<u32, E>; // people may expect that you will check the value of the `u32`I suggested that we could actually just get some real word data on this using crater. My thought was, we could do an experiment were we error on any function that (after monomorphization) returns I do expect that this will result in a non-small amount of cases, but I think it might be a small enough set that we could browse through and get a sense of if this type of thing is relied upon. Would you be interested in doing that experiment @WaffleLapkin? If not, I'm happy to help out and try that myself (or I can help if you do want to be involved). |
|
@jackh726 I'd be happy to do the experiment. I might reach out for some help though ^^' |
|
Sounds good! Let me know, happy to help if you run into issues. |
17a892b to
69a5724
Compare
This comment has been minimized.
This comment has been minimized.
|
Copying this from #148577 (comment) So, what's very clear is that this pattern comes in a lot of places. Definitely more than I would have expected coming into this. With this being said, I've gone through and opened a few crater results to see if I could spot any examples of @joshtriplett's concern, which was basically like "People may be relying on that So, going into this, I'm looking for types where the That being said, given that this comes up so much, I think this decision is likely not as "light" as the lang team originally expected. Though, it's completely backwards- and forwards- compatible to make this change and undo later. Here a couple of examples of code I saw, though far from exhaustive.
|
|
📋 This PR cannot be approved because it currently has the following label: |
|
@bors r=fee1-dead |
This comment has been minimized.
This comment has been minimized.
Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint This is an extension to #147382. With this PR `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` considered as must use iif `T` must be used. For such cases the lint will mention that `T` is wrapped in a `Result`/`ControlFlow` with an uninhabited error/break. The reasoning here is that `Result<T, Uninhabited>` is equivalent to `T` in which values can be represented and thus the must-used-ness should also be equivalent. Fixes #65861
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #156361. |
|
Unknown argument "dist-x86_64-apple". Did you mean to use |
|
@bors try jobs=dist-x86_64-apple |
This comment has been minimized.
This comment has been minimized.
Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint try-job: dist-x86_64-apple
…, r=fee1-dead Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint This is an extension to rust-lang#147382. With this PR `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` considered as must use iif `T` must be used. For such cases the lint will mention that `T` is wrapped in a `Result`/`ControlFlow` with an uninhabited error/break. The reasoning here is that `Result<T, Uninhabited>` is equivalent to `T` in which values can be represented and thus the must-used-ness should also be equivalent. Fixes rust-lang#65861
Rollup of 5 pull requests Successful merges: - #148214 (Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint) - #149362 (Add Command::get_resolved_envs) - #155188 (Add regression test for issue 144329) - #155515 (error on empty `export_name`) - #155817 (validate `#[link_name = "..."]` & `#[link(name = "...")]` parameters)
…, r=fee1-dead Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint This is an extension to rust-lang#147382. With this PR `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` considered as must use iif `T` must be used. For such cases the lint will mention that `T` is wrapped in a `Result`/`ControlFlow` with an uninhabited error/break. The reasoning here is that `Result<T, Uninhabited>` is equivalent to `T` in which values can be represented and thus the must-used-ness should also be equivalent. Fixes rust-lang#65861
…, r=fee1-dead Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint This is an extension to rust-lang#147382. With this PR `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` considered as must use iif `T` must be used. For such cases the lint will mention that `T` is wrapped in a `Result`/`ControlFlow` with an uninhabited error/break. The reasoning here is that `Result<T, Uninhabited>` is equivalent to `T` in which values can be represented and thus the must-used-ness should also be equivalent. Fixes rust-lang#65861
…uwer Rollup of 10 pull requests Successful merges: - #148214 (Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint) - #149362 (Add Command::get_resolved_envs) - #155705 (Add `str::word_to_titlecase()` to `alloc`) - #155970 (Add mention of sendfile(2) and splice(2) to fs::copy() documentation.) - #156006 (Update a bunch of bootstrap dependencies to remove windows-target) - #155188 (Add regression test for issue 144329) - #155515 (error on empty `export_name`) - #155817 (validate `#[link_name = "..."]` & `#[link(name = "...")]` parameters) - #156107 (remove turbofish notation + use None / Some instead of Option:: (in match documentation)) - #156133 (mark some panicking methods around Duration as track_caller)
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 82bee96 (parent) -> ce89c89 (this PR) Test differencesShow 2 test diffs2 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard ce89c898570852a1bb441d77570596e50bf362c2 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (ce89c89): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary -2.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 497.725s -> 498.161s (0.09%) |
View all comments
This is an extension to #147382.
With this PR
Result<T, Uninhabited>andControlFlow<Uninhabited, T>considered as must use iifTmust be used.For such cases the lint will mention that
Tis wrapped in aResult/ControlFlowwith an uninhabited error/break.The reasoning here is that
Result<T, Uninhabited>is equivalent toTin which values can be represented and thus the must-used-ness should also be equivalent.Fixes #65861